<template>
  <div class="app-download">
    <img :src="require('@/assets/app-bg.png')" alt="">
  </div>
</template>

<script>
  export default {
    data () {
      return {
        promoteCode: ''
      }
    },
    mounted () {
      const ua = navigator.userAgent
      const isiOS = ua.match(/iPhone|iPod|iPad/i)
      const isAndroid = ua.match(/Android/i)
      const lua = navigator.userAgent.toLowerCase()
      // eslint-disable-next-line
      const isWeChat = lua.match(/MicroMessenger/i) == 'micromessenger'
      // const isPC = !isiOS && !isAndroid

      // apk命名
      const apkName = this.promoteCode === '' ? 'fenmiaojinrong' : `fmjrapp_${this.promoteCode}`
      if (isWeChat) {
        return
      } else if (isiOS) {
        setTimeout(function () {
          window.location = 'https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1231293266&mt=8'
        }, 100)
      } else if (isAndroid) {
        setTimeout(() => {
          window.location = `https://www.fenmiaojinrong.com/upload/upload/${apkName}.apk?time=${new Date()}`
        }, 100)
      }
    },
    created () {
      if (this.$route.query['c'] && this.$route.query['c'] !== '') {
        this.promoteCode = this.$route.query['c']
      }
    }
}
</script>

<style lang='scss'>
  .app-download {
    width: 100%;
    height: 100%;
    background: #fff;
    img {
      width: 100%;
    }
  }
</style>
